package murcielago.tokenizer;

import java.io.IOException;
import java.util.Hashtable;
import javax.microedition.media.MediaException;
import murcielago.phonema.RegPhonema;
import murcielago.player.Player;

public class Tokenizer {
    
    private String text;
    private Player player;
    private Hashtable hash;

    public Tokenizer(String text){
        this.text = text;
        try {
            this.player = new Player();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
        this.hash = new Hashtable();
        LoadHash.Load(hash); 
        this.particionar();
    }

    private void particionar(){
        //llamar al metodo static de RegPhonema
        String[] tokens = RegPhonema.obtainTokens(this.text);

        /*for(int i = 0; i < tokens.length; i++){
             //this.player.cargarQueue( ((String) this.hash.get(String.valueOf(tokens[i]))) );
        }*/
        for(int i = tokens.length-1; i == 0; i--){
            this.player.cargarStack( ((String) this.hash.get(String.valueOf(tokens[i]))) );
        }

        this.player.play();
    }

}
